ProtoGeniDefs.pm.in 10.3 KB
Newer Older
1 2
#!/usr/bin/perl -w
#
Leigh B Stoller's avatar
Leigh B Stoller committed
3
# Copyright (c) 2008-2019 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
# 
# {{{GENIPUBLIC-LICENSE
# 
# GENI Public License
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
# 
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
# 
# }}}
#
package ProtoGeniDefs;

use strict;
use English;
use GeniResponse;
use GeniCertificate;

#
# Each of the packages added themself to this hash.
#
my %MODULES = ();

sub AddModule($$)
{
    my ($name, $module) = @_;

    if (exists($module->{'PEMFILE'})) {
	my $certificate = GeniCertificate->LoadFromFile($module->{'PEMFILE'});
	if (!defined($certificate)) {
	    print STDERR "Could not load certificate: " .
		$module->{'PEMFILE'} . "\n";
	}
	else {
	    $module->{'CERTIFICATE'} = $certificate;
	}
    }
    $MODULES{$name} = $module;
}
sub Module($)
{
    my ($name) = @_;

    return undef
	if (!exists($MODULES{$name}));
    
    return $MODULES{$name};
}

#
# Stub
#
sub GetVersion()
{
    if (1) {
	my $mypid = main::WrapperFork();
	if ($mypid) {
	    return GeniResponse->Create(GENIRESPONSE_SUCCESS, 1.0);
	}
	sleep(10);
	return 0;
    }
    return GeniResponse->Create(GENIRESPONSE_SUCCESS, 1.0);
}

AddModule("root",
	  {
	      "PEMFILE"    => "@prefix@/etc/emulab.pem",
	      "DEFVERSION" => "01",
	      "METHODS"  => {"01" => {
		  "GetVersion" => \&GetVersion,
	      }},
	  });

93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
package ProtoGeniDefs::ProtogeniCH;

use lib '@prefix@/lib';
use GeniCH;

ProtoGeniDefs::AddModule("ch",
	  {
	      "PEMFILE"    => "@prefix@/etc/genich.pem",
	      "DBNAME"     => "geni-ch",
	      "DEFVERSION" => "1",
	      "INITMODULE" => \&GeniCH::InitModule,
	      "METHODS"    => {"1" => {
		  "GetVersion"            => \&GeniCH::GetVersion,
		  "GetCredential"         => \&GeniCH::GetCredential,
		  "Resolve"               => \&GeniCH::Resolve,
		  "Register"              => \&GeniCH::Register,
		  "Remove"                => \&GeniCH::Remove,
		  "ListComponents"        => \&GeniCH::ListComponents,
		  "PostCRL"               => \&GeniCH::PostCRL,
		  "Shutdown"              => \&GeniCH::Shutdown,
		  "List"                  => \&GeniCH::List,
		  "WhoAmI"		  => \&GeniCH::WhoAmI,
		  "PostHistoryRecord"	  => \&GeniCH::PostHistoryRecord,
		  "ReadHistoryRecords"    => \&GeniCH::ReadHistoryRecords,
		  "ListActiveSlivers"     => \&GeniCH::ListActiveSlivers,
	      }},
	  });

121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
package ProtoGeniDefs::ProtogeniSA;

use lib '@prefix@/lib';
use GeniSA;

ProtoGeniDefs::AddModule("sa",
	  {
	      "PEMFILE"    => "@prefix@/etc/genisa.pem",
	      "DBNAME"     => "geni",
	      "DEFVERSION" => "1.01",
	      "METHODS"    => {"1.01" => {
		  "GetVersion"        => \&GeniSA::GetVersion,
		  "GetCredential"     => \&GeniSA::GetCredential,
		  "Resolve"           => \&GeniSA::Resolve,
		  "Register"          => \&GeniSA::Register,
		  "Remove"            => \&GeniSA::Remove,
		  "GetKeys"	      => \&GeniSA::GetKeys,
		  "BindToSlice"	      => \&GeniSA::BindToSlice,
		  "Shutdown"          => \&GeniSA::Shutdown,
		  "RenewSlice"        => \&GeniSA::RenewSlice,
		  "RegisterSliver"    => \&GeniSA::RegisterSliver,
		  "UnRegisterSliver"  => \&GeniSA::UnRegisterSliver,
	      }},
	  });

package ProtoGeniDefs::ProtogeniCM;
use vars qw($V2_METHODS);

use lib '@prefix@/lib';
use GeniCM;
use GeniCMV2;

$V2_METHODS = {
    "GetVersion"        => \&GeniCMV2::GetVersion,
    "Resolve"	        => \&GeniCMV2::Resolve,
    "DiscoverResources" => \&GeniCMV2::DiscoverResources,
    "CreateSliver"      => \&GeniCMV2::CreateSliver,
    "UpdateSliver"      => \&GeniCMV2::UpdateSliver,
    "DeleteSliver"      => \&GeniCMV2::DeleteSliver,
    "GetSliver"         => \&GeniCMV2::GetSliver,
    "Shutdown"          => \&GeniCMV2::Shutdown,
    "SliverStatus"      => \&GeniCMV2::SliverStatus,
    "RenewSlice"        => \&GeniCMV2::RenewSlice,
    "GetTicket"         => \&GeniCMV2::GetTicket,
    "ReleaseTicket"     => \&GeniCMV2::ReleaseTicket,
    "UpdateTicket"      => \&GeniCMV2::UpdateTicket,
    "RedeemTicket"      => \&GeniCMV2::RedeemTicket,
    "DeleteSlice"       => \&GeniCMV2::DeleteSlice,
    "StartSliver"       => \&GeniCMV2::StartSliver,
    "StopSliver"        => \&GeniCMV2::StopSliver,
    "RestartSliver"     => \&GeniCMV2::RestartSliver,
    "ReloadSliver"      => \&GeniCMV2::ReloadSliver,
    "BindToSlice"       => \&GeniCMV2::BindToSlice,
    "ListUsage"         => \&GeniCMV2::ListUsage,
    "ListHistory"       => \&GeniCMV2::ListHistory,
    "ReserveVlanTags"   => \&GeniCMV2::ReserveVlanTags,
    "InjectEvent"       => \&GeniCMV2::InjectEvent,
    "CreateImage"       => \&GeniCMV2::CreateImage,
    "DeleteImage"       => \&GeniCMV2::DeleteImage,
    "ImageInfo"         => \&GeniCMV2::ImageInfo,
    "ListImages"        => \&GeniCMV2::ListImages,
    "ShareLan"          => \&GeniCMV2::ShareLan,
    "UnShareLan"        => \&GeniCMV2::UnShareLan,
    "ListActiveSlivers" => \&GeniCMV2::ListActiveSlivers,
    "ConsoleURL"	=> \&GeniCMV2::ConsoleURL,
    "ConsoleInfo"	=> \&GeniCMV2::ConsoleInfo,
    "CreateDataset"     => \&GeniCMV2::CreateDataset,
    "DeleteDataset"     => \&GeniCMV2::DeleteDataset,
    "DescribeDataset"   => \&GeniCMV2::DescribeDataset,
    "ModifyDataset"     => \&GeniCMV2::ModifyDataset,
191
    "ApproveDataset"    => \&GeniCMV2::ApproveDataset,
192
    "GetDatasetCredential" => \&GeniCMV2::GetDatasetCredential,
193
    "SecureImageDownload"  => \&GeniCMV2::SecureImageDownload,
194 195 196 197 198 199
    "Lockdown"          => \&GeniCMV2::Lockdown,
    "TriggerImageUpdate"=> \&GeniCMV2::TriggerImageUpdate,
    "AddNodes"          => \&GeniCMV2::AddNodes,
    "DeleteNodes"       => \&GeniCMV2::DeleteNodes,
    "Panic"             => \&GeniCMV2::Panic,
    "RunLinktest"       => \&GeniCMV2::RunLinktest,
Leigh B Stoller's avatar
Leigh B Stoller committed
200
    "Recovery"          => \&GeniCMV2::Recovery,
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
};

ProtoGeniDefs::AddModule("cm",
	  {
	      "PEMFILE"    => "@prefix@/etc/genicm.pem",
	      "DBNAME"     => "geni-cm",
	      "DEFVERSION" => "2.0",
	      "METHODS"    => {"2.0" => $V2_METHODS},
	  });

package ProtoGeniDefs::ProtogeniAM;
use vars qw($V2_METHODS $V3_METHODS);

use lib '@prefix@/lib';
use GeniAM;

$V2_METHODS = {
        "GetVersion"    => \&GeniAM::GetVersion,
        "ListResources" => \&GeniAM::ListResources,
        "CreateSliver"  => \&GeniAM::CreateSliver,
        "DeleteSliver"  => \&GeniAM::DeleteSliver,
        "SliverStatus"  => \&GeniAM::SliverStatus,
        "RenewSliver"   => \&GeniAM::RenewSliver,
        "Shutdown"      => \&GeniAM::Shutdown,
        "CreateImage"   => \&GeniAM::CreateImage,
        "DeleteImage"   => \&GeniAM::DeleteImage,
        "ListImages"    => \&GeniAM::ListImages,
};
$V3_METHODS = {
        "GetVersion"    => \&GeniAM::GetVersion,
        "ListResources" => \&GeniAM::ListResources,
	"Describe"      => \&GeniAM::Describe,
	"Allocate"      => \&GeniAM::Allocate,
	"Renew"         => \&GeniAM::Renew,
	"Provision"     => \&GeniAM::Provision,
	"Status"        => \&GeniAM::Status,
	"PerformOperationalAction" => \&GeniAM::PerformOperationalAction,
	"Delete"        => \&GeniAM::Delete,
	"Shutdown"      => \&GeniAM::Shutdown,
	"Update"        => \&GeniAM::Update,
        "Cancel"        => \&GeniAM::Cancel,
        "CreateImage"   => \&GeniAM::CreateImage,
        "DeleteImage"   => \&GeniAM::DeleteImage,
        "ListImages"    => \&GeniAM::ListImages,
};

ProtoGeniDefs::AddModule("am",
	  {
	      "PEMFILE"    => "@prefix@/etc/genicm.pem",
	      "DBNAME"     => "geni-cm",
	      "DEFVERSION" => "2.0",
	      "INITMODULE" => \&GeniAM::InitModule,
	      "METHODS"    => {"1.0" => $V2_METHODS,
			       "2.0" => $V2_METHODS,
			       "3.0" => $V3_METHODS},
	      "CONVERTER"  => {"1.0" => \&GeniAM::ConvertResponseV1,
			       "2.0" => \&GeniAM::ConvertResponseV2,
			       "3.0" => \&GeniAM::ConvertResponseV2},
	  });

package ProtoGeniDefs::ProtogeniCluster;

use lib '@prefix@/lib';
use GeniCluster;

ProtoGeniDefs::AddModule("cluster",
	  {
	      "PEMFILE"    => "@prefix@/etc/genicm.pem",
269
	      "DBNAME"     => "geni-cm",
270 271
	      "DEFVERSION" => "1.0",
	      "METHODS"    => {"1.0" => {
272
		  "GetVersion"           => \&GeniCluster::GetVersion,
273
		  "CreateUser"           => \&GeniCluster::CreateUser,
274 275 276
		  "InUse"                => \&GeniCluster::InUse,
		  "PreReservations"      => \&GeniCluster::PreReservations,
		  "SliceUtilizationData" => \&GeniCluster::SliceUtilizationData,
277
		  "SliceIdleData"        => \&GeniCluster::SliceIdleData,
278
		  "SliceOpenstackData"   => \&GeniCluster::SliceOpenstackData,
279
		  "SliceCheckReservation"=> \&GeniCluster::SliceCheckReservation,
280
		  "SliceMaxExtension"    => \&GeniCluster::SliceMaxExtension,
281 282
		  "Reserve"              => \&GeniCluster::Reserve,
		  "Reservations"         => \&GeniCluster::Reservations,
283
		  "ApproveReservation"   => \&GeniCluster::ApproveReservation,
284
		  "DeleteReservation"    => \&GeniCluster::DeleteReservation,
285
		  "ReservationSystemInfo"=> \&GeniCluster::ReservationSystemInfo,
Leigh B Stoller's avatar
Leigh B Stoller committed
286
		  "ReservationPrediction"=> \&GeniCluster::ReservationPrediction,
287
		  "ReservationHistory"   => \&GeniCluster::ReservationHistory,
288
		  "CancelReservation"    => \&GeniCluster::CancelReservation,
289 290 291
	      }},
	  });

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
package ProtoGeniDefs::ProtogeniIMS;

use lib '@prefix@/lib';
use GeniIMS;

ProtoGeniDefs::AddModule("ims",
	  {
	      "PEMFILE"    => "@prefix@/etc/genich.pem",
	      "DBNAME"     => "geni-ch",
	      "DEFVERSION" => "1.01",
	      "METHODS"    => {"1.01" => {
		  "GetVersion"        => \&GeniIMS::GetVersion,
		  "GetCredential"     => \&GeniIMS::GetCredential,
		  "PostImageInfo"     => \&GeniIMS::PostImageInfo,
		  "GetImageInfo"      => \&GeniIMS::GetImageInfo,
		  "DeleteImageInfo"   => \&GeniIMS::DeleteImageInfo,
	      }},
	  });

311 312
1;