import datetime
import time
-import traceback
import sys
-import re
-from types import StringTypes
-from sfa.util.faults import *
+from sfa.util.faults import RecordNotFound, SliverDoesNotExist
from sfa.util.xrn import get_authority, hrn_to_urn, urn_to_hrn, Xrn, urn_to_sliver_id
-from sfa.util.plxrn import slicename_to_hrn, hrn_to_pl_slicename, hostname_to_urn
-from sfa.util.record import SfaRecord
-from sfa.util.policy import Policy
-from sfa.util.record import *
+from sfa.util.plxrn import slicename_to_hrn, hrn_to_pl_slicename
+#from sfa.util.record import *
+from sfa.util.version import version_core
+from sfa.util.sfatime import utcparse
+from sfa.util.callids import Callids
+
from sfa.trust.sfaticket import SfaTicket
-from sfa.plc.slices import Slices
from sfa.trust.credential import Credential
+from sfa.rspecs.version_manager import VersionManager
+from sfa.rspecs.rspec import RSpec
+
import sfa.plc.peers as peers
-from sfa.plc.network import *
from sfa.plc.api import SfaAPI
from sfa.plc.aggregate import Aggregate
-from sfa.plc.slices import *
-from sfa.util.version import version_core
-from sfa.rspecs.version_manager import VersionManager
-from sfa.rspecs.rspec import RSpec
-from sfa.util.sfatime import utcparse
-from sfa.util.callids import Callids
+from sfa.plc.slices import Slices
+#unused?
+#from sfa.plc.network import *
+#from sfa.plc.slices import *
def GetVersion(api):
"""
"""
- hrn, type = urn_to_hrn(slice_xrn)
+ hrn, _ = urn_to_hrn(slice_xrn)
hrn_auth = get_authority(hrn)
def SliverStatus(api, slice_xrn, creds, call_id):
if Callids().already_handled(call_id): return {}
- (hrn, type) = urn_to_hrn(slice_xrn)
+ (hrn, _) = urn_to_hrn(slice_xrn)
# find out where this slice is currently running
slicename = hrn_to_pl_slicename(hrn)
nodes = api.plshell.GetNodes(api.plauth, {'node_id':slice['node_ids'],'peer_id':None},
['node_id', 'hostname', 'site_id', 'boot_state', 'last_contact'])
site_ids = [node['site_id'] for node in nodes]
- sites = api.plshell.GetSites(api.plauth, site_ids, ['site_id', 'login_base'])
- sites_dict = dict ( [ (site['site_id'],site['login_base'] ) for site in sites ] )
result = {}
top_level_status = 'unknown'
res['geni_status'] = 'ready'
else:
res['geni_status'] = 'failed'
- top_level_staus = 'failed'
+ top_level_status = 'failed'
res['geni_error'] = ''
aggregate = Aggregate(api)
slices = Slices(api)
- (hrn, type) = urn_to_hrn(slice_xrn)
+ (hrn, _) = urn_to_hrn(slice_xrn)
peer = slices.get_peer(hrn)
sfa_peer = slices.get_sfa_peer(hrn)
slice_record=None
def RenewSliver(api, xrn, creds, expiration_time, call_id):
if Callids().already_handled(call_id): return True
- (hrn, type) = urn_to_hrn(xrn)
+ (hrn, _) = urn_to_hrn(xrn)
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
if not slices:
return False
def start_slice(api, xrn, creds):
- hrn, type = urn_to_hrn(xrn)
+ (hrn, _) = urn_to_hrn(xrn)
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
if not slices:
return 1
def stop_slice(api, xrn, creds):
- hrn, type = urn_to_hrn(xrn)
+ hrn, _ = urn_to_hrn(xrn)
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
if not slices:
if not slice_tags:
api.plshell.AddSliceTag(api.plauth, slice_id, 'enabled', '0')
elif slice_tags[0]['value'] != "0":
- tag_id = attributes[0]['slice_tag_id']
+ tag_id = slice_tags[0]['slice_tag_id']
api.plshell.UpdateSliceTag(api.plauth, tag_id, '0')
return 1
def DeleteSliver(api, xrn, creds, call_id):
if Callids().already_handled(call_id): return ""
- (hrn, type) = urn_to_hrn(xrn)
+ (hrn, _) = urn_to_hrn(xrn)
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename})
if not slices:
if Callids().already_handled(call_id): return ""
# get slice's hrn from options
xrn = options.get('geni_slice_urn', None)
- (hrn, type) = urn_to_hrn(xrn)
+ (hrn, _) = urn_to_hrn(xrn)
version_manager = VersionManager()
# get the rspec's return format from options
def get_ticket(api, xrn, creds, rspec, users):
- reg_objects = __get_registry_objects(xrn, creds, users)
+#unused
+# reg_objects = __get_registry_objects(xrn, creds, users)
- slice_hrn, type = urn_to_hrn(xrn)
- slices = Slices(api)
- peer = slices.get_peer(slice_hrn)
- sfa_peer = slices.get_sfa_peer(slice_hrn)
+ (slice_hrn, _) = urn_to_hrn(xrn)
+#unused
+# slices = Slices(api)
+# peer = slices.get_peer(slice_hrn)
+# sfa_peer = slices.get_sfa_peer(slice_hrn)
# get the slice record
registry = api.registries[api.hrn]
# similar to CreateSliver, we must verify that the required records exist
# at this aggregate before we can issue a ticket
- site_id, remote_site_id = slices.verify_site(registry, credential, slice_hrn,
- peer, sfa_peer, reg_objects)
- slice = slices.verify_slice(registry, credential, slice_hrn, site_id,
- remote_site_id, peer, sfa_peer, reg_objects)
+#Error (E1121, get_ticket): Too many positional arguments for function call
+#unused anyway
+# site_id, remote_site_id = slices.verify_site(registry, credential, slice_hrn,
+# peer, sfa_peer, reg_objects)
+#Error (E1121, get_ticket): Too many positional arguments for function call
+#unused anyway
+# slice = slices.verify_slice(registry, credential, slice_hrn, site_id,
+# remote_site_id, peer, sfa_peer, reg_objects)
# make sure we get a local slice record
record = None
for tmp_record in records:
if tmp_record['type'] == 'slice' and \
not tmp_record['peer_authority']:
+#Error (E0602, get_ticket): Undefined variable 'SliceRecord'
record = SliceRecord(dict=tmp_record)
if not record:
raise RecordNotFound(slice_hrn)
def main():
- api = SfaAPI()
"""
rspec = ListResources(api, "plc.princeton.sapan", None, 'pl_test_sapan')
#rspec = ListResources(api, "plc.princeton.coblitz", None, 'pl_test_coblitz')
#rspec = ListResources(api, "plc.pl.sirius", None, 'pl_test_sirius')
print rspec
"""
+ api = SfaAPI()
f = open(sys.argv[1])
xml = f.read()
f.close()
+#Error (E1120, main): No value passed for parameter 'users' in function call
+#Error (E1120, main): No value passed for parameter 'call_id' in function call
CreateSliver(api, "plc.princeton.sapan", xml, 'CreateSliver_sapan')
if __name__ == "__main__":